﻿@model S4Store.Models.AfterSaleReport.SparePartModel
@{
    Layout = null;
    ViewBag.Title = "SaleTimeRate";
    var container = "div" + Guid.NewGuid().ToString();
    var config = Model.MonthConfigs.FirstOrDefault();
}
<div style="height:100%; overflow:auto">
@Html.Action("ReportBar", "Common", Model.BarModel)
<div class="pagetitle">
    备件库存管理关键KPI
</div>
@if(config==null)
    {
        <text>数据未配置</text>
    }else{

<div style="position:relative; width:100%">
    @{
        
        var 目标在库天数 = config.PJZKTSMB;
        //b6/f6
        // 库    存    成   本   总   量/日    均   备   件   销   售   成   本
        var 实际在库天数 = config.RJBJXSCB == 0 ? 0 : config.KCCBZL / config.RJBJXSCB;

        var 目标备件周转率 = config.BJZZLMB;
        //=SUM((G6*12)/E6)
        //=(月     备       件      销        售        成          本*12)/((月   初     库   存   成   本+月   末   库   存   成   本)/2)
        var 实际备件周转率 = Model.BJZZL(Model.BarModel.Month.Year, Model.BarModel.Month.Month);

        var 目标备件保修合格率 = config.BJBXHGLMB;
        //=SUM(O6/N6)
        //=保       修        合         格       件              数/申       请          保      修          总         件           数
        var 实际备件保修合格率 = Model.BJBXHGL(Model.BarModel.Month.Year,Model.BarModel.Month.Month);

        var 目标订货率 = config.ZCDHLMB;
        //=SUM(H6/I6)
        //=月           计            划              订            货           成            本/月          全          部           订       货        成         本
        var 实际订货率 = (config.YQBDHCB == 0 ? 0 : config.YJHDHCB / config.YQBDHCB) * 100;

        var 目标备件满足率 = config.BJMZLMB;
        //=SUM(1-(P6/Q6))
        //1-(缺   件  未       维        修      台          次/月          维           修          总          台          次)
        var 实际备件满足率 = (config.YWXZTC == 0 ? 0 : 1 - (config.QJWWXTC / config.YWXZTC)) * 100;
        
        //图表
        S4Store.Models.Chart.Column ChartModel = new S4Store.Models.Chart.Column();
        ChartModel.Colors = new List<string> { S4Store.Models.Chart.Color.Green, S4Store.Models.Chart.Color.Blue };

        ChartModel.IsRate = false;
        //ChartModel.Name = "平均在库天数";
        ChartModel.YAxis = "天数";
        ChartModel.XAxis.Add("平均在库天数天数");
        //ChartModel.Width = 500;
        //ChartModel.Height = 300;

        S4Store.Models.Chart.ChartSeries series1 = new S4Store.Models.Chart.ChartSeries();
        series1.Name = "目标";
        series1.Data.Add(目标在库天数);
        ChartModel.Serieses.Add(series1);

        
        S4Store.Models.Chart.ChartSeries series2 = new S4Store.Models.Chart.ChartSeries();
        series2.Name = "实际";
        series2.Data.Add(实际在库天数);
        ChartModel.Serieses.Add(series2);

        S4Store.Models.Chart.Column ChartModel1 = new S4Store.Models.Chart.Column();
        ChartModel1.Colors = new List<string> { S4Store.Models.Chart.Color.Green, S4Store.Models.Chart.Color.Blue };

        ChartModel1.YAxis = "%";
        ChartModel1.XAxis.Add("备件保修合格率");
        ChartModel1.XAxis.Add("正常订货率");
        ChartModel1.XAxis.Add("备件满足率");
        
        S4Store.Models.Chart.ChartSeries series11 = new S4Store.Models.Chart.ChartSeries();
        series11.Name = "目标";
        series11.Data.Add(目标备件保修合格率);
        series11.Data.Add(目标订货率);
        series11.Data.Add(目标备件满足率);
        ChartModel1.Serieses.Add(series11);

        S4Store.Models.Chart.ChartSeries series110 = new S4Store.Models.Chart.ChartSeries();
        series110.Name = "实际";
        series110.Data.Add(实际备件保修合格率);
        series110.Data.Add(实际订货率);
        series110.Data.Add(实际备件满足率);
        ChartModel1.Serieses.Add(series110);




        S4Store.Models.Chart.Column ChartModel4 = new S4Store.Models.Chart.Column();
        ChartModel4.Colors = new List<string> { S4Store.Models.Chart.Color.Green, S4Store.Models.Chart.Color.Blue };

        ChartModel4.IsRate = false;
        //ChartModel4.Name = "备件周转率";
        ChartModel4.YAxis = "次/年";
        ChartModel4.XAxis.Add("备件周转率");
        //ChartModel.Width = 500;
        //ChartModel.Height = 300;

        S4Store.Models.Chart.ChartSeries series41 = new S4Store.Models.Chart.ChartSeries();
        series41.Name = "目标";
        series41.Data.Add(目标备件周转率);
        ChartModel4.Serieses.Add(series41);


        S4Store.Models.Chart.ChartSeries series42 = new S4Store.Models.Chart.ChartSeries();
        series42.Name = "实际";
        series42.Data.Add(实际备件周转率);
        ChartModel4.Serieses.Add(series42);
        
    
        <table border="0" style=" width:100%">
            <tr>
                <td style=" width:25%;">
        @Html.Partial("../Chart/Column", ChartModel)
        <div style=" margin-left:70px; overflow:hidden">
        <table style="width:100%">
            <tr>
                <td align="center" width="30">
                @if (实际在库天数 > 目标在库天数)
                {
                    <a class="middlered" href="@Url.Action("ZKTS")" target="navtab" title="在库天数">
                         @Math.Round((实际在库天数 - 目标在库天数), 0, MidpointRounding.AwayFromZero)
                    </a>
                }
                else
                {
                    <a class="middlegreen" href="@Url.Action("ZKTS")" target="navtab" title="在库天数">
                         @Math.Round((实际在库天数 - 目标在库天数),0,MidpointRounding.AwayFromZero)
                    </a>
                }

                </td>
            </tr>
        </table>
        </div>
                </td>
                <td style=" width:25%">
                    @Html.Partial("../Chart/Column", ChartModel4)
                    <div style=" margin-left:70px; overflow:hidden">
                    <table style="width:100%">
                        <tr>
                            <td align="center" width="30">
                            @if (实际备件周转率 < 目标备件周转率)
                            {
                                <a class="middlered" href="@Url.Action("BJZZL")" target="navtab" title="备件周转率">
                                     @Math.Round((实际备件周转率 - 目标备件周转率),0,MidpointRounding.AwayFromZero)
                                </a>
                            }
                            else
                            {
                                <a class="middlegreen" href="@Url.Action("BJZZL")" target="navtab" title="备件周转率">
                                     @Math.Round((实际备件周转率 - 目标备件周转率),0,MidpointRounding.AwayFromZero)
                                </a>
                            }

                            </td>
                        </tr>
                    </table>
                    </div>
                </td>
        <td>
            @Html.Partial("../Chart/Column", ChartModel1)
            <div style=" padding-left:70px;">
            <table style="width:100%">
            <tr>
                <td align="center" width="30">
                     @if (实际备件保修合格率 < 目标备件保修合格率)
                {
                    <a class="middlered" href="@Url.Action("BJBXHGL")" target="navtab" title="备件保修合格率">
                        @Math.Round((实际备件保修合格率 - 目标备件保修合格率),0,MidpointRounding.AwayFromZero)
                    </a>
                }
                else
                {
                    <a class="middlegreen" href="@Url.Action("BJBXHGL")" target="navtab" title="备件保修合格率">
                         @Math.Round((实际备件保修合格率 - 目标备件保修合格率),0,MidpointRounding.AwayFromZero)
                    </a>
                }
                </td>
                <td align="center" width="30">
                     @if (实际订货率 < 目标订货率)
                {
                    <a class="middlered" href="@Url.Action("ZCDHL")" target="navtab" title="正常订货率">
                         @Math.Round((实际订货率 - 目标订货率),0,MidpointRounding.AwayFromZero)
                    </a>
                }
                else
                {
                    <a class="middlegreen" href="@Url.Action("ZCDHL")" target="navtab" title="正常订货率">
                         @Math.Round((实际订货率 - 目标订货率),0,MidpointRounding.AwayFromZero)
                    </a>
                }
                </td>
                <td align="center" width="30">
                     @if (实际备件满足率  < 目标备件满足率)
                {
                    <a class="middlered" href="@Url.Action("BJMZL")" target="navtab" title="备件满足率">
                         @Math.Round((实际备件满足率 - 目标备件满足率),0,MidpointRounding.AwayFromZero)
                    </a>
                }
                else
                {
                    <a class="middlegreen" href="@Url.Action("BJMZL")" target="navtab" title="备件满足率">
                        @Math.Round((实际备件满足率 - 目标备件满足率),0,MidpointRounding.AwayFromZero)
                    </a>
                }
                </td>
            </tr>
            </table>
            </div>
        </td>
        </tr>
        </table>
        
        }
</div>
    }
</div>